package com.hiultra.archive.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hiultra.common.annotation.Log;
import com.hiultra.common.core.controller.BaseController;
import com.hiultra.common.core.domain.AjaxResult;
import com.hiultra.common.enums.BusinessType;
import com.hiultra.archive.domain.ArcCheckDetails;
import com.hiultra.archive.service.IArcCheckDetailsService;
import com.hiultra.common.utils.poi.ExcelUtil;
import com.hiultra.common.core.page.TableDataInfo;

/**
 * 资产盘点子Controller
 * 
 * @author ls
 * @date 2023-09-05
 */
@RestController
@RequestMapping("/archive/checkDetails")
public class ArcCheckDetailsController extends BaseController
{
    @Autowired
    private IArcCheckDetailsService arcCheckDetailsService;

    /**
     * 查询资产盘点子列表
     */
    @PreAuthorize("@ss.hasPermi('archive:checkDetails:list')")
    @GetMapping("/list")
    public TableDataInfo list(ArcCheckDetails arcCheckDetails)
    {
        startPage();
        List<ArcCheckDetails> list = arcCheckDetailsService.selectArcCheckDetailsList(arcCheckDetails);
        return getDataTable(list);
    }

    /**
     * 导出资产盘点子列表
     */
    @PreAuthorize("@ss.hasPermi('archive:checkDetails:export')")
    @Log(title = "资产盘点子", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ArcCheckDetails arcCheckDetails)
    {
        List<ArcCheckDetails> list = arcCheckDetailsService.selectArcCheckDetailsList(arcCheckDetails);
        ExcelUtil<ArcCheckDetails> util = new ExcelUtil<ArcCheckDetails>(ArcCheckDetails.class);
        util.exportExcel(response, list, "资产盘点子数据");
    }

    /**
     * 获取资产盘点子详细信息
     */
    @PreAuthorize("@ss.hasPermi('archive:checkDetails:query')")
    @GetMapping(value = "/{detailId}")
    public AjaxResult getInfo(@PathVariable("detailId") Long detailId)
    {
        return AjaxResult.success(arcCheckDetailsService.selectArcCheckDetailsByDetailId(detailId));
    }

    /**
     * 新增资产盘点子
     */
    @PreAuthorize("@ss.hasPermi('archive:checkDetails:add')")
    @Log(title = "资产盘点子", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ArcCheckDetails arcCheckDetails)
    {
        return toAjax(arcCheckDetailsService.insertArcCheckDetails(arcCheckDetails));
    }

    /**
     * 修改资产盘点子
     */
    @PreAuthorize("@ss.hasPermi('archive:checkDetails:edit')")
    @Log(title = "资产盘点子", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ArcCheckDetails arcCheckDetails)
    {
        return toAjax(arcCheckDetailsService.updateArcCheckDetails(arcCheckDetails));
    }

    /**
     * 删除资产盘点子
     */
    @PreAuthorize("@ss.hasPermi('archive:checkDetails:remove')")
    @Log(title = "资产盘点子", businessType = BusinessType.DELETE)
	@DeleteMapping("/{detailIds}")
    public AjaxResult remove(@PathVariable Long[] detailIds)
    {
        return toAjax(arcCheckDetailsService.deleteArcCheckDetailsByDetailIds(detailIds));
    }
}
